package cn.hou.java.designpattern._07observer;


// 被观察者: 需要继承Observable抽象类
public class Person extends java.util.Observable {
	private String name;
	private Integer age;
	public void setAge(Integer age) {
		this.age = age;
		this.setChanged();//声明对象已被改变,必须调用
		//对象改变时通知所所有观察者
		this.notifyObservers();
	}
	public void setName(String name) {
		this.name = name;
		this.setChanged();//对象已被改变
		this.notifyObservers(name);
	}
	public Integer getAge() {
		return age;
	}
	public String getName() {
		return name;
	}

}
